package com.example.repository;

import com.example.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserRepository {
    @Select("SELECT * FROM users WHERE id = #{id}")
    User getUserById(@Param("id") String id);

    @Insert("INSERT INTO users (id, name, sex, age, email, phone_number) VALUES (#{id}, #{name}, #{sex}, #{age}, #{email}, #{phoneNumber})")
    void insertUser(User user);

    @Update("UPDATE users SET name = #{name}, sex = #{sex}, age = #{age}, email = #{email}, phone_number = #{phoneNumber} WHERE id = #{id}")
    void updateUser(User user);

    @Delete("DELETE FROM users WHERE id = #{id}")
    void deleteUserById(@Param("id") String id);

    @Select("SELECT * FROM users")
    List<User> getAllUsers();
}